package com.csd.action.manager;

import com.csd.helper.ActionResult;
import com.csd.helper.ProjectState;
import com.csd.pojo.EvaluateItem;
import com.csd.pojo.Project;
import com.csd.pojo.Teacher;
import com.csd.service.IEvaluateItemService;

/**
 * 為項目分配一個評審老師
 * @author sanmu
 *	<br>創建於2009-12-29
 */
public class EvaluationTeacherAddAction 
{
	
	private Integer projectID;
	
	private Integer teacherID;
	
	private String stage;
	
	private IEvaluateItemService evaluateItemService;
	

	public String getStage() {
		return stage;
	}

	public void setStage(String stage) {
		this.stage = stage;
	}

	public Integer getProjectID() {
		return projectID;
	}

	public void setProjectID(Integer prijectID) {
		this.projectID = prijectID;
	}

	public Integer getTeacherID() {
		return teacherID;
	}

	public void setTeacherID(Integer teacherID) {
		this.teacherID = teacherID;
	}

	public IEvaluateItemService getEvaluateItemService() {
		return evaluateItemService;
	}

	public void setEvaluateItemService(IEvaluateItemService evaluateItemService) {
		this.evaluateItemService = evaluateItemService;
	}
	
	public String execute()throws Exception{
		String text = ActionResult.fail;
		boolean bl = false;
		EvaluateItem eItem = new EvaluateItem();
		Project project = new Project();
		String state="";
		if(stage.equals("1"))
			state = ProjectState.beforeStage;
		else if(stage.equals("2"))
			state = ProjectState.middleStage;
		else if(stage.equals("3"))
			state = ProjectState.afterStage;
		else
			return text;
		eItem.setStage(state);
		project.setId(projectID);
		Teacher teacher = new Teacher();
		teacher.setId(teacherID);
		eItem.setProject(project);
		eItem.setTeacher(teacher);
		eItem.setGrade(0);
		//保存评审项
		bl = evaluateItemService.saveEvaluateItem(eItem);
		
		if (bl) 
		{
			text = ActionResult.success;
		}
		return text;
	}
}
